package com.uenpay.im.ui.old.activity.label;

import com.qiyunxin.android.http.utils.StringUtils;
import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author SL
 * @created 2015-12-28 12:48:59
 * @copyRight http://www.qiyunxin.com
 * @function 修改标签
 */
public class UpdateLabelInvokeItem extends BaseHttpInvokeItem {
	public class UpdateLabelInvokeItemResult extends HttpInvokeResult {
	}

	public UpdateLabelInvokeItemResult getOutput() {
		return (UpdateLabelInvokeItemResult) GetResultObject();
	}

	public UpdateLabelInvokeItem(int tagid, String tagname, String custids) {
		String url = APIConfiguration.getBaseUrl()
				+ "Friend/Friend/updateTag?tagid=" + tagid + "&tagname="
				+ StringUtils.encodeParams(tagname) + "&custids=" + custids + "&"
				+ APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		UpdateLabelInvokeItemResult result = new UpdateLabelInvokeItemResult();
		JSONObject json = null;
		try {
			json = new JSONObject(responseBody);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		if (json == null) {
			return null;
		}
		result.status = json.optInt("status");
		result.msg = json.optString("msg");
		return result;
	}

}
